-
-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow timeago to be used with jquery-livequery #30
base: master
Are you sure you want to change the base?
Conversation
$('attr.timeago').livequery(function() { $(this).timeago(); }); - Save intervalId to only issue setInterval once - Add selected elements to a global array which we query
Would like to see this pull request make it in too! |
Yep me too |
The included code works great, but has a performance problem. The elements array does not remove elements that are no longer visible on the page. I added the following code to remove elements that aren't visible: $.fn.timeago = function() {
var self = this;
self.each(refresh);
// Only keep the elements that aren't hidden
var visibleElements = [];
$.each(elements, function(i, e) {
if (!$(e).is(':hidden')) {
visibleElements.push(e);
}
});
elements = visibleElements;
... |
I agree. Timeago being "accurate" to the minute, it would be make sense to have dynamically added elements updated too. It would defeat timeago's purpose if this feature or some similar solution is not implemented. |
+1 :/ |
+1 on merdjemak's comment. Hope this pull request makes it too |
@cburgmer you should remove the Hope this pull request gets accepted... it's a major improvement even if you don't use jquery-livequery |
Me too. |
+1 |
Hello, this was opened a long time ago (no pun intended). |
I use timeago with livequery on my site like this: $("time.timeago").livequery( ->
$(this).timeago()
) |
livequery extends selectors to find elements "even after the page has been loaded and the DOM updated".
This patch extends timeago to be used in conjunction with livequery.
The changes are pretty simple but simply not very pretty. I'd be happy if this idea would go into timeago even in a different form.